home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / gofer221.zip / PARSER.C < prev    next >
C/C++ Source or Header  |  1991-11-20  |  39KB  |  1,266 lines

  1. /* A YACC parser generated from "parser.y" */
  2.  
  3. # line 12
  4. #ifndef lint
  5. #define lint
  6. #endif
  7. #define typeDefn(line,lhs,rhs)     newTypeDefn(intOf(line),lhs,rhs,FALSE)
  8. #define dataDefn(line,lhs,rhs)     newTypeDefn(intOf(line),lhs,rhs,TRUE)
  9. #define sigdecl(l,vs,t)         ap(SIGDECL,triple(l,vs,t))
  10. #define grded(gs)         ap(GUARDED,gs)
  11. #define letrec(bs,e)         (nonNull(bs) ? ap(LETREC,pair(bs,e)) : e)
  12. #define yyerror(s)         /* errors handled elsewhere */
  13. #define YYSTYPE             Cell
  14.  
  15. static Cell   local gcShadow     Args((Int,Cell));
  16. static Void   local syntaxError  Args((String));
  17. static String local unexpected   Args((Void));
  18. static Cell   local checkPrec    Args((Cell));
  19. static Void   local fixDefn      Args((Syntax,Cell,Cell,List));
  20. static Void   local setSyntax    Args((Int,Syntax,Cell));
  21. static Cell   local buildTuple   Args((List));
  22. static Cell   local checkClass   Args((Cell));
  23. static List   local checkContext Args((List));
  24. static Cell   local tidyInfix    Args((Cell));
  25.  
  26. /* For the purposes of reasonably portable garbage collection, it is
  27.  * necessary to simulate the YACC stack on the Gofer stack to keep
  28.  * track of all intermediate constructs.  The lexical analyser
  29.  * pushes a token onto the stack for each token that is found, with
  30.  * these elements being removed as reduce actions are performed,
  31.  * taking account of look-ahead tokens as described by gcShadow()
  32.  * below.
  33.  *
  34.  * Of the non-terminals used below, only start and topdecl do not leave
  35.  * any values of the Gofer stack.  The same is true for the terminals
  36.  * EVALEX and MODULE.  At the end of a successful parse, there should only
  37.  * be one element left on the stack, containing the result of the parse.
  38.  */
  39.  
  40. #define gc0(e)             gcShadow(0,e)
  41. #define gc1(e)             gcShadow(1,e)
  42. #define gc2(e)             gcShadow(2,e)
  43. #define gc3(e)             gcShadow(3,e)
  44. #define gc4(e)             gcShadow(4,e)
  45. #define gc5(e)             gcShadow(5,e)
  46. #define gc6(e)             gcShadow(6,e)
  47.  
  48. #define EVALEX 257
  49. #define MODULE 258
  50. #define SCRIPT 259
  51. #define COCO 260
  52. #define INFIXL 261
  53. #define INFIXR 262
  54. #define INFIX 263
  55. #define FUNARROW 264
  56. #define UPTO 265
  57. #define CASEXP 266
  58. #define OF 267
  59. #define IF 268
  60. #define THEN 269
  61. #define ELSE 270
  62. #define WHERE 271
  63. #define TYPE 272
  64. #define DATA 273
  65. #define FROM 274
  66. #define LET 275
  67. #define IN 276
  68. #define VAROP 277
  69. #define VARID 278
  70. #define NUMLIT 279
  71. #define CHARLIT 280
  72. #define STRINGLIT 281
  73. #define REPEAT 282
  74. #define CONOP 283
  75. #define CONID 284
  76. #define TCLASS 285
  77. #define IMPLIES 286
  78. #define TINSTANCE 287
  79. #define PRIMITIVE 288
  80. #define yyclearin yychar = -1
  81. #define yyerrok yyerrflag = 0
  82. extern int yychar;
  83. extern short yyerrflag;
  84. #ifndef YYMAXDEPTH
  85. #define YYMAXDEPTH 150
  86. #endif
  87. #ifndef YYSTYPE
  88. #define YYSTYPE int
  89. #endif
  90. YYSTYPE yylval, yyval;
  91. # define YYERRCODE 256
  92.  
  93. #line 346
  94.  
  95.  
  96. static Cell local gcShadow(n,e)        /* keep parsed fragments on stack  */
  97. Int  n;
  98. Cell e; {
  99.     /* If a look ahead token is held then the required stack transformation
  100.      * is:
  101.      *   pushed: n               1     0          1     0
  102.      *           x1  |  ...  |  xn  |  la   ===>  e  |  la
  103.      *                                top()            top()
  104.      *
  105.      * Othwerwise, the transformation is:
  106.      *   pushed: n-1             0        0
  107.      *           x1  |  ...  |  xn  ===>  e
  108.      *                         top()     top()
  109.      */
  110.     if (yychar>=0) {
  111.     pushed(n-1) = top();
  112.         pushed(n)   = e;
  113.     }
  114.     else
  115.     pushed(n-1) = e;
  116.     sp -= (n-1);
  117.     return e;
  118. }
  119.  
  120. static Void local syntaxError(s)       /* report on syntax error           */
  121. String s; {
  122.     ERROR(row) "Syntax error in %s (unexpected %s)", s, unexpected()
  123.     EEND;
  124. }
  125.  
  126. static String local unexpected() {    /* find name for unexpected token  */
  127.     static char buffer[100];
  128.     switch (yychar) {
  129.     case 0           : return "end of input";
  130.  
  131. #define keyword(kw) sprintf(buffer,"\"%s\" keyword",kw); return buffer;
  132.     case INFIXL    : keyword("infixl");
  133.     case INFIXR    : keyword("infixr");
  134.     case INFIX     : keyword("infix");
  135.     case TINSTANCE : keyword("instance");
  136.     case TCLASS    : keyword("class");
  137.     case PRIMITIVE : keyword("primitive");
  138.     case CASEXP    : keyword("case");
  139.     case OF        : keyword("of");
  140.     case IF        : keyword("if");
  141.     case THEN      : keyword("then");
  142.     case ELSE      : keyword("else");
  143.     case WHERE     : keyword("where");
  144.     case TYPE      : keyword("type");
  145.     case DATA      : keyword("data");
  146.     case LET       : keyword("let");
  147.     case IN        : keyword("in");
  148. #undef keyword
  149.  
  150.     case FUNARROW  : return "`->'";
  151.     case '='       : return "`='";
  152.     case COCO      : return "`::'";
  153.     case '-'       : return "`-'";
  154.     case ','       : return "comma";
  155.     case '@'       : return "`@'";
  156.     case '('       : return "`('";
  157.     case ')'       : return "`)'";
  158.     case '|'       : return "`|'";
  159.     case ';'       : return "`;'";
  160.     case UPTO      : return "`..'";
  161.     case '['       : return "`['";
  162.     case ']'       : return "`]'";
  163.     case FROM      : return "`<-'";
  164.     case '\\'      : return "`\\'";
  165.     case '~'       : return "`~'";
  166.     case '`'       : return "``'";
  167.     case VAROP     :
  168.     case VARID     :
  169.     case CONOP     :
  170.     case CONID     : sprintf(buffer,"symbol \"%s\"",
  171.                  textToStr(textOf(yylval)));
  172.              return buffer;
  173.     case NUMLIT    : return "numeric literal";
  174.     case CHARLIT   : return "character literal";
  175.     case STRINGLIT : return "string literal";
  176.     case IMPLIES   : return "`=>";
  177.     default           : return "token";
  178.     }
  179. }
  180.  
  181. static Cell local checkPrec(p)         /* Check for valid precedence value */
  182. Cell p; {
  183.     if (!isInt(p) || intOf(p)<MIN_PREC || intOf(p)>MAX_PREC) {
  184.         ERROR(row) "Precedence value must be an integer in the range [%d..%d]",
  185.                    MIN_PREC, MAX_PREC
  186.         EEND;
  187.     }
  188.     return p;
  189. }
  190.  
  191. static Void local fixDefn(a,line,p,ops)/* Declare syntax of operators      */
  192. Syntax a;
  193. Cell   line;
  194. Cell   p;
  195. List   ops; {
  196.     Int l = intOf(line);
  197.     a     = mkSyntax(a,intOf(p));
  198.     map2Proc(setSyntax,l,a,ops);
  199. }
  200.  
  201. static Void local setSyntax(line,sy,op)/* set syntax of individ. operator  */
  202. Int    line;
  203. Syntax sy;
  204. Cell   op; {
  205.     addSyntax(line,textOf(op),sy);
  206.     opDefns = cons(op,opDefns);
  207. }
  208.  
  209. static Cell local buildTuple(tup)      /* build tuple (x1,...,xn) from list*/
  210. List tup; {                            /* [xn,...,x1]                      */
  211.     Int  n = 0;
  212.     Cell t = tup;
  213.     Cell x;
  214.  
  215.     do {                               /*     .                    .       */
  216.         x      = fst(t);               /*    / \                  / \      */
  217.         fst(t) = snd(t);               /*   xn  .                .   xn    */
  218.         snd(t) = x;                    /*        .    ===>      .          */
  219.         x      = t;                    /*         .            .           */
  220.         t      = fun(x);               /*          .          .            */
  221.         n++;                           /*         / \        / \           */
  222.     } while (nonNull(t));              /*        x1  NIL   (n)  x1         */
  223.     fst(x) = mkTuple(n);
  224.     return tup;
  225. }
  226.  
  227. /* The yacc parser presented above is not sufficiently powerful to
  228.  * determine whether a tuple at the front of a sigType is part of a
  229.  * context:    e.g. (Eq a, Num a) => a -> a -> a
  230.  * or a type:  e.g.  (Tree a, Tree a) -> Tree a
  231.  *
  232.  * Rather than complicate the grammar, both are parsed as tuples of types,
  233.  * using the following checks afterwards to ensure that the correct syntax
  234.  * is used in the case of a tupled context.
  235.  */
  236.  
  237. static List local checkContext(con)    /* validate type class context       */
  238. Type con; {
  239.     if (con==UNIT)            /* allows empty context ()       */
  240.     return NIL;
  241.     else if (whatIs(getHead(con))==TUPLE) {
  242.     List qs = NIL;
  243.  
  244.     while (isAp(con)) {        /* undo work of buildTuple  :-(    */
  245.         Cell temp = fun(con);
  246.         fun(con)  = arg(con);
  247.         arg(con)  = qs;
  248.         qs          = con;
  249.         con       = temp;
  250.         checkClass(hd(qs));
  251.     }
  252.     return qs;
  253.     }
  254.     else                /* single context expression       */
  255.     return singleton(checkClass(con));
  256. }
  257.  
  258. static Cell local checkClass(c)        /* check that type expr is a class */
  259. Cell c; {                /* constrnt of the form C t1 .. tn */
  260.     Cell cn = getHead(c);
  261.  
  262.     if (!isCon(cn))
  263.     syntaxError("class expression");
  264.     else if (argCount<1) {
  265.     ERROR(row) "Class \"%s\" must have at least one argument",
  266.            textToStr(textOf(cn))
  267.     EEND;
  268.     }
  269.     return c;
  270. }
  271.  
  272. /* expressions involving a sequence of two or more infix operator symbols
  273.  * are parsed as elements of type:
  274.  *    InfixExpr ::= [Expr]
  275.  *         |  ap(ap(Operator,InfixExpr),Expr)
  276.  *
  277.  * thus x0 +1 x1 ... +n xn is parsed as: +n (....(+1 [x0] x1)....) xn
  278.  *
  279.  * Once the expression has been completely parsed, this parsed form is
  280.  * `tidied' according to the precedences and associativities declared for
  281.  * each operator symbol.
  282.  *
  283.  * The tidy process uses a `stack' of type:
  284.  *    TidyStack ::= ap(ap(Operator,TidyStack),Expr)
  285.  *         |  NIL
  286.  * when the ith layer of an InfixExpr has been transferred to the stack, the
  287.  * stack is of the form: +i (....(+n NIL xn)....) xi
  288.  *
  289.  * The tidy function is based on a simple shift-reduce parser:
  290.  *
  291.  *  tidy                :: InfixExpr -> TidyStack -> Expr
  292.  *  tidy [m]   ss        = foldl (\x f-> f x) m ss
  293.  *  tidy (m*n) []        = tidy m [(*n)]
  294.  *  tidy (m*n) ((+o):ss)
  295.  *           | amb     = error "Ambiguous"
  296.  *           | shift   = tidy m ((*n):(+o):ss)
  297.  *           | reduce  = tidy (m*(n+o)) ss
  298.  *               where sye     = syntaxOf (*)
  299.  *                 (ae,pe) = sye
  300.  *                 sys     = syntaxOf (+)
  301.  *                 (as,ps) = sys
  302.  *                 amb     = pe==ps && (ae/=as || ae==NON_ASS)
  303.  *                 shift   = pe>ps || (ps==pe && ae==LEFT_ASS)
  304.  *                 reduce  = otherwise
  305.  *
  306.  * N.B. the conditions amb, shift, reduce are NOT mutually exclusive and
  307.  * must be tested in that order.
  308.  *
  309.  * As a concession to efficiency, we lower the number of calls to syntaxOf
  310.  * by keeping track of the values of sye, sys throughout the process.  The
  311.  * value APPLIC is used to indicate that the syntax value is unknown.
  312.  */
  313.  
  314. static Cell local tidyInfix(e)         /* convert InfixExpr to Expr        */
  315. Cell e; {                              /* :: InfixExpr                     */
  316.     Cell   s   = NIL;                  /* :: TidyStack                     */
  317.     Syntax sye = APPLIC;               /* Syntax of op in e (init unknown) */
  318.     Syntax sys = APPLIC;               /* Syntax of op in s (init unknown) */
  319.     Cell   temp;
  320.  
  321.     while (nonNull(tl(e))) {
  322.         if (isNull(s)) {
  323.             s           = e;
  324.             e           = arg(fun(s));
  325.             arg(fun(s)) = NIL;
  326.             sys         = sye;
  327.             sye         = APPLIC;
  328.         }
  329.         else {
  330.             if (sye==APPLIC) {         /* calculate sye (if unknown)       */
  331.                 sye = syntaxOf(textOf(fun(fun(e))));
  332.                 if (sye==APPLIC) sye=DEF_OPSYNTAX;
  333.             }
  334.             if (sys==APPLIC) {         /* calculate sys (if unknown)       */
  335.                 sys = syntaxOf(textOf(fun(fun(s))));
  336.                 if (sys==APPLIC) sys=DEF_OPSYNTAX;
  337.             }
  338.  
  339.             if (precOf(sye)==precOf(sys) &&                      /* amb    */
  340.                    (assocOf(sye)!=assocOf(sys) || assocOf(sye)==NON_ASS)) {
  341.                 ERROR(row) "Ambiguous use of operator \"%s\" with \"%s\"",
  342.                            textToStr(textOf(fun(fun(e)))),
  343.                            textToStr(textOf(fun(fun(s))))
  344.                 EEND;
  345.             }
  346.             else if (precOf(sye)>precOf(sys) ||                  /* shift  */
  347.                        (precOf(sye)==precOf(sys) && assocOf(sye)==LEFT_ASS)) {
  348.                 temp        = arg(fun(e));
  349.                 arg(fun(e)) = s;
  350.                 s           = e;
  351.                 e           = temp;
  352.                 sys         = sye;
  353.                 sye         = APPLIC;
  354.             }
  355.             else {                                               /* reduce */
  356.                 temp        = arg(fun(s));
  357.                 arg(fun(s)) = arg(e);
  358.                 arg(e)      = s;
  359.                 s           = temp;
  360.                 sys         = APPLIC;
  361.                 /* sye unchanged */
  362.             }
  363.         }
  364.     }
  365.  
  366.     e = hd(e);
  367.     while (nonNull(s)) {
  368.         temp        = arg(fun(s));
  369.         arg(fun(s)) = e;
  370.         e           = s;
  371.         s           = temp;
  372.     }
  373.  
  374.     return e;
  375. }
  376.  
  377. /*-------------------------------------------------------------------------*/
  378. short yyexca[] ={
  379. -1, 1,
  380.     0, -1,
  381.     -2, 0,
  382. -1, 77,
  383.     260, 84,
  384.     44, 84,
  385.     -2, 109,
  386. -1, 87,
  387.     286, 22,
  388.     -2, 21,
  389. -1, 135,
  390.     264, 26,
  391.     286, 26,
  392.     -2, 60,
  393. -1, 224,
  394.     264, 26,
  395.     283, 26,
  396.     -2, 18,
  397. -1, 225,
  398.     264, 29,
  399.     283, 29,
  400.     -2, 19,
  401.     };
  402. #define YYNPROD 154
  403. # define YYLAST 651
  404. short yyact[]={
  405.  
  406.   21, 191, 152, 122,  97,  14, 231, 253,  94, 157,
  407.   98, 186, 125, 132, 203, 132,  32, 219, 204,  21,
  408.  193, 190,  83,  84,  14, 245, 179, 216, 276, 153,
  409.   42, 121,  38,  21, 256,  85,  82, 187,  14, 244,
  410.  129,  94,   4,   2,   3, 180, 144, 245, 252, 232,
  411.  140,  26,  21, 166, 229,  19, 151,  14,  78,  95,
  412.   21,  54,  35,  30,  64,  51, 177,  65, 139, 142,
  413.   26, 199,  21, 185,  19,  86,  31,  14, 163, 222,
  414.  162,  44, 214, 111,  26, 118,  18, 112,  19,  21,
  415.   75, 139,  95, 133,  14,  49, 235, 206, 212, 233,
  416.  120, 213,  15,  26, 118,  18, 124,  19,  21, 101,
  417.   81,  26,   6, 226, 217,  19,  44,  47, 107,  18,
  418.   94, 172, 210,  26,   5, 211, 148,  19,  21, 170,
  419.   36,  37, 145,  14, 145,  94, 242, 271,  18, 102,
  420.   26,   6, 239,  55,  19, 116,  18, 101,  61, 134,
  421.  134,  21, 241, 175,  47, 168, 171, 106,  18,  26,
  422.  107, 167, 103,  19,  21, 243,  56, 113, 137, 123,
  423.  117,  95, 182, 183, 194,  18,  41, 126, 127,  26,
  424.    6, 174,  40,  19, 104, 202,  95, 105, 115, 146,
  425.  198, 240, 118,  62,  18,  60,  13, 205,  59,  33,
  426.   20, 147,  26, 118,  58, 150,  19,  27, 118, 143,
  427.  141, 118, 255, 192,  18,  26, 119, 189, 196,  19,
  428.  128,  69,  70,  71,  89, 159, 228, 164,  88, 165,
  429.  218, 130,  67,  68, 169, 119, 173,  18,  29,  22,
  430.   23,  24,  25, 178,  28,  73,  93,  74,  72,  66,
  431.   18,  29,  92,  29,  69,  70,  71,  29,  22,  23,
  432.   24,  25,  43,  28, 197,  67,  68, 200,  45, 188,
  433.  149,  29,  22,  23,  24,  25,  11,  28,  73,  93,
  434.   74,  72, 265, 178, 272, 155,   9, 176,   8, 184,
  435.   29,  22,  23,  24,  25,   7,  28,  52,  29,  22,
  436.   23,  24,  25,  53,  28,  11, 277, 138, 114, 273,
  437.   29,  22,  23,  24,  25,   9,  28,   8, 264, 176,
  438.  257, 234,  87, 119,   7, 236, 237,  29,  22,  23,
  439.   24,  25, 268,  28, 119, 201,  89, 263, 248, 119,
  440.  250, 251, 119, 259,  11, 221,  29,  22,  23,  24,
  441.   25,  89,  28,  63,   9, 261, 260, 262,  93,  90,
  442.    1,  91, 257,   7,  92, 266,  29,  22,  23,  24,
  443.   25, 181,  28,  93, 249,  79,  10,   0,  17, 225,
  444.    0,   0, 275,   0,  39,  46,   0,   0,   0,  29,
  445.   22,  23,  24,  25, 238,  28, 136, 136, 279,  12,
  446.    0,   0,  29,  22,  23,  24,  25,  76,  28,  77,
  447.  176,   0,  76,   0,  77,   0,   0, 158, 160,  16,
  448.    0,  57,   0,   0,   0,   0,  34,   0,   0, 108,
  449.    0,   0,   0, 135, 135,  48,   0,   0,  50,  96,
  450.    0,   0, 176,   0, 270,   0,  99,   0, 274,   0,
  451.    0, 131, 154,  80, 156,  76,   0,  77,   0,   0,
  452.    0,   0,   0,   0,   0,   0,   0,  48, 161, 100,
  453.    0,   0,   0,   0,   0, 208, 209,   0, 109, 110,
  454.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  455.    0,   0,   0,  76,   0,  77,   0, 154,   0,   0,
  456.  220,   0, 223,   0,   0,   0,   0, 227,  96,   0,
  457.    0,   0,   0,   0,   0,   0,   0,   0, 195,   0,
  458.    0,   0,   0,   0,   0,  76,   0,  77, 207,   0,
  459.    0,   0,   0,   0, 246,   0, 247,   0,   0, 224,
  460.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  461.    0, 230,   0,   0,   0,   0,   0,   0,   0,   0,
  462.    0, 215,   0,   0, 131,   0,   0,   0,   0,   0,
  463.    0,   0,   0,   0,   0, 223, 269,   0,   0,   0,
  464.    0,   0,   0,   0,   0,   0, 154, 156,   0,   0,
  465.    0,   0, 154, 156,   0, 278,   0,   0, 254,   0,
  466.    0,   0,   0,   0,   0,   0, 258,   0,  77,  76,
  467.    0,  77, 224,   0,   0,   0, 207,   0,   0,   0,
  468.    0,   0, 267,   0,   0,   0,   0,   0,   0,   0,
  469.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  470.    0,   0,   0,   0,   0,   0,   0,   0, 258,   0,
  471.   77 };
  472. short yypact[]={
  473.  
  474. -214,-1000,  49, -60,-1000,-255, 124, -61,  49,  49,
  475. -228,-1000, -15, -15, 124, 124,-1000,  31, 124,-1000,
  476. -1000,  20,-1000,-1000,-1000,-1000,  49,-1000,-1000,-1000,
  477.   -7,-1000, -65, 111,-1000,  32,-247,-244,  80,  32,
  478. -1000,-1000,-1000,-1000,-274,-1000,  32, 124,-1000, 124,
  479. -1000,  68,  98, 121,-1000, 143, 116, -15, 124, 124,
  480.  -10,  43,  74,  86,-1000,-1000,-1000,-253,-253,-267,
  481. -267,-267, -25,  80,  80,  47,   8,  31,  32,  49,
  482. -1000,  67,-1000,  49, -67,-1000,-284,-1000,-235,-1000,
  483.    1,-1000,   1,-1000, -32,  80, -15, -16, -18,-1000,
  484. -1000,-1000,-1000,-1000,-1000,  49,-1000,  49,  12, 120,
  485.  114,-1000,  49,  49,  49,-1000, -40,-1000,-1000,-1000,
  486.    5,-1000,-1000, -35, -15,-1000, -15, -15,  29,-1000,
  487. -1000,-270,  -8,-250,-285,   1,-1000,-251,  80, -27,
  488. -1000,-255,  49,  10,-1000,  49,  67,-1000, -21,-262,
  489. -252,  32,  80,  80,-1000,-1000,-1000,-1000,  81,  57,
  490.  -11,  32,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-238,
  491.   70,-1000, -44,-1000,-1000,-1000,-1000,  80,-1000,  95,
  492.   69,-1000,  69,  69,  80, -27,-1000, 106,  98,-1000,
  493.  -69,-278,-1000, -74,-1000,-1000,-1000,  55,-1000,  49,
  494.   35,-1000,-1000,  49,  49,  83,-1000, -99,-1000,-1000,
  495. -1000,  80,-1000,  80,-1000,-1000,  49,  49,  49,  49,
  496. -1000, -76,-1000,-276,   1,   1, -15,-1000,-1000,  32,
  497.    1,   1,  32,  88,  55,  49,-1000,-1000,-1000, -21,
  498. -1000,-255, -77,  49,-1000,  32,-1000,-1000,-1000,-1000,
  499. -1000,-1000,  95,  80,-1000,  78,-1000,  24,   8,  67,
  500.   49,-1000,-1000,-1000,-1000,-1000,-1000,-236,-1000,-1000,
  501. -1000, -21,  80,-1000,-1000,-247,  49,-1000,-1000,-1000 };
  502. short yypgo[]={
  503.  
  504.    0, 360, 121,  76, 353, 188,  64,  36, 100, 322,
  505.  345,  79, 359,  35,  75, 228, 361, 225, 106,  45,
  506.  371, 182, 176, 220,  40, 378,  93, 217, 213, 212,
  507.  110,  34,  90, 376,  50, 210, 209,  46, 207, 200,
  508.  199, 197, 419, 399, 196, 102, 166, 195,  97, 191,
  509.  152, 136,  39, 129, 156, 170 };
  510. short yyr1[]={
  511.  
  512.    0,   1,   1,   1,   1,   4,   4,   4,   4,   4,
  513.    6,   6,   8,   8,   8,  10,  10,  11,  11,  11,
  514.   13,  13,  14,   9,   9,   9,  15,  15,  16,  16,
  515.   16,  16,  16,  16,  12,  12,  17,  17,   6,   6,
  516.    6,  18,  18,  19,  19,  20,  20,  20,  21,  21,
  517.   22,  22,   6,  23,  23,  23,  24,   6,   6,  26,
  518.   26,  27,  27,  28,  28,  29,  29,  31,  31,   7,
  519.    7,  30,  30,  34,  34,  35,  35,   3,  36,  36,
  520.   37,  37,  37,  32,  32,  25,  25,  38,  38,  39,
  521.   39,   2,   2,   2,   2,   2,   2,   2,  40,  40,
  522.   33,  33,  33,  44,  44,  43,  43,  45,  45,  42,
  523.   42,  42,  42,  42,  42,  42,  42,  42,  42,  42,
  524.   42,  42,  42,  42,  42,  46,  46,  41,  41,  48,
  525.   49,  49,  50,  50,  51,  51,  52,  47,  47,  47,
  526.   47,  47,  47,  47,  47,  53,  53,  54,  54,  54,
  527.    5,   5,  55,  55 };
  528. short yyr2[]={
  529.  
  530.    0,   2,   3,   4,   1,   3,   3,   1,   1,   1,
  531.    4,   4,   2,   1,   1,   3,   1,   3,   1,   1,
  532.    3,   1,   1,   1,   3,   1,   1,   1,   1,   1,
  533.    2,   3,   3,   3,   2,   2,   3,   3,   3,   3,
  534.    3,   1,   0,   3,   1,   1,   1,   1,   1,   3,
  535.    1,   3,   4,   3,   1,   1,   2,   3,   3,   3,
  536.    1,   4,   0,   4,   0,   3,   1,   3,   2,   3,
  537.    2,   3,   1,   2,   1,   2,   1,   4,   2,   1,
  538.    4,   5,   4,   3,   1,   1,   3,   1,   3,   1,
  539.    3,   4,   6,   6,   6,   3,   1,   1,   2,   1,
  540.    1,   3,   1,   3,   5,   2,   1,   2,   1,   1,
  541.    3,   2,   1,   1,   2,   1,   1,   1,   1,   3,
  542.    3,   3,   4,   4,   4,   3,   3,   3,   1,   2,
  543.    2,   1,   1,   2,   2,   1,   4,   0,   1,   1,
  544.    3,   3,   4,   2,   5,   3,   1,   3,   3,   1,
  545.    2,   1,   1,   1 };
  546. short yychk[]={
  547.  
  548. -1000,  -1, 257, 258, 256,  -2,  92, 275, 268, 266,
  549.  -33, 256, -43, -44,  45, -45, -42, -25, 126,  95,
  550.  -39,  40, 279, 280, 281, 282,  91, -38, 284, 278,
  551.  123,  -3, 271, -40, -42, 123,  -2,  -2, 260, -20,
  552.  -21, -22,  45, 277,  96, 283, -20, -45, -42,  64,
  553.  -42,  45, 277, 283,  41,  -2, -46, -43, -21, -22,
  554.  -47,  -2, -46,  -4,  -6,  -7, 256, 272, 273, 261,
  555.  262, 263, 288, 285, 287, -32, -33, -25, 123, 264,
  556.  -42, -30,  -7, 269, 267, -13, -14,  -9, -15, 256,
  557.  -12, -16, 284, 278,  40,  91, -43, 278, 284, -43,
  558.  -42,  41,  41,  41,  41,  44,  41,  44, -20, -42,
  559.  -42,  93,  44, 124, 265,  -5,  59, -55, 125, 256,
  560.   -8, 284, 256,  -8, -18, 279, -18, -18, -23, -24,
  561.  256, -25,  40, -26, -14, -12,  -9, -26, 260,  44,
  562.  -34, -35,  61, -36, -37, 124, -30,  -2,  59,  -5,
  563.   -2, 123, 286, 264, -16, 284, -16,  41,  -9, -17,
  564.   -9, -20,  96,  96,  -2,  -2,  41,  41,  41,  -2,
  565.  -53, -54,  -2,  -2,  -6,  -7, -55,  61, 278,  61,
  566.  -19, -20, -19, -19, 260,  44, 281,  45, 277, -27,
  567.  271, 286, -28, 271, -13, -25,  -3,  -2, -37,  61,
  568.   -2,  -5,  -7, 276, 270, -41, -48, -33,  -9,  -9,
  569.   41,  44,  41,  44,  93, -43, 265,  44, 274,  61,
  570.   -9, -10, -11,  -9, -12, 284,  44,  -9, -24, 123,
  571.  -12, 284, 123,  44,  -2,  61,  -2,  -2,  -5,  59,
  572.  -49, -50, -51, 264, -52, 124,  -9,  -9,  -2, -54,
  573.   -2,  -2, 124, 283, -20, -29, -31, -32, -33, -30,
  574.  268,  -2,  -2, -48,  -3, -52,  -2, -33, -11,  -9,
  575.   -5,  59, 260, -34,  -5,  -2, 264, -31,  -9,  -2 };
  576. short yydef[]={
  577.  
  578.    0,  -2,   0,   0,   4,   1,   0,   0,   0,   0,
  579.   96,  97, 100, 102,   0, 106, 108, 109,   0, 112,
  580.  113,   0, 115, 116, 117, 118, 137,  85,  89,  87,
  581.    0,   2,   0,   0,  99,   0,   0,   0,   0,   0,
  582.   45,  46,  47,  48,   0,  50,   0, 105, 107,   0,
  583.  111,   0,  48,  50, 114,   0,   0, 100,   0,   0,
  584.    0, 138, 139,   0,   7,   8,   9,   0,   0,  42,
  585.   42,  42,   0,   0,   0,   0,   0,  -2,   0,   0,
  586.   98,   0,  72,   0,   0,  95,   0,  -2,  23,  25,
  587.   26,  27,  29,  28,   0,   0, 101,   0,   0, 103,
  588.  110,  86,  88,  90, 119,   0, 120,   0,   0,   0,
  589.    0, 121,   0,   0, 143,   3,   0, 151, 152, 153,
  590.    0,  13,  14,   0,   0,  41,   0,   0,   0,  54,
  591.   55,   0,   0,  62,   0,  -2,  22,  64,   0,   0,
  592.   70,  74,   0,  76,  79,   0,   0,  91,   0,   0,
  593.    0,   0,   0,   0,  34,  29,  35,  30,   0,   0,
  594.    0,   0,  49,  51, 126, 125, 122, 123, 124, 126,
  595.  140, 146, 149, 141,   5,   6, 150,   0,  12,   0,
  596.   38,  44,  39,  40,   0,   0,  56,   0,   0,  57,
  597.    0,   0,  58,   0,  69,  83,  73,  75,  78,   0,
  598.    0,  77,  71,   0,   0,   0, 128,   0,  20,  24,
  599.   31,   0,  32,   0,  33, 104, 142,   0,   0,   0,
  600.   10,  11,  16,   0,  -2,  -2,   0,  52,  53,   0,
  601.   59,   0,   0,   0,   0,   0,  92,  93,  94,   0,
  602.  129, 131, 132,   0, 135,   0,  37,  36, 144, 145,
  603.  147, 148,   0,   0,  43,   0,  66,   0,   0,   0,
  604.    0,  82,  80, 127, 130, 134, 133,   0,  15,  17,
  605.   61,   0,   0,  68,  63,  81,   0,  65,  67, 136 };
  606. #define YYFLAG   -1000
  607. #define YYERROR  goto yyerrlab
  608. #define YYACCEPT return(0)
  609. #define YYABORT  return(1)
  610.  
  611. /*      parser for yacc output  */
  612.  
  613. #ifdef YYDEBUG
  614. int yydebug     = 0;     /* 1 for debugging */
  615. #endif
  616. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  617. int yychar      = -1;    /* current input token number */
  618. int yynerrs     = 0;     /* number of errors */
  619. short yyerrflag = 0;     /* error recovery flag */
  620.  
  621. int yyparse() {
  622.     short yys[YYMAXDEPTH];
  623.     short yyj, yym;
  624.     register YYSTYPE *yypvt;
  625.     register short yystate, *yyps, yyn;
  626.     register YYSTYPE *yypv;
  627.     register short *yyxi;
  628.  
  629.     yystate   = 0;
  630.     yychar    = -1;
  631.     yynerrs   = 0;
  632.     yyerrflag = 0;
  633.     yyps      = &yys[-1];
  634.     yypv      = &yyv[-1];
  635.  
  636. yystack:    /* put a state and value onto the stack */
  637.  
  638. #ifdef YYDEBUG
  639.     if (yydebug)
  640.         printf("state %d, char 0%o\n", yystate, yychar);
  641. #endif
  642.     if(++yyps>&yys[YYMAXDEPTH]) {
  643.         yyerror("yacc stack overflow");
  644.         return(1);
  645.     }
  646.     *yyps = yystate;
  647.     ++yypv;
  648. #ifdef UNION
  649.     yyunion(yypv, &yyval);
  650. #else
  651.     *yypv = yyval;
  652. #endif
  653.  
  654. yynewstate:
  655.  
  656.     yyn = yypact[yystate];
  657.  
  658.     if (yyn<=YYFLAG)
  659.         goto yydefault; /* simple state */
  660.  
  661.     if (yychar<0)
  662.         if ((yychar=yylex())<0)
  663.             yychar=0;
  664.     if ((yyn+=yychar)<0 || yyn>=YYLAST)
  665.         goto yydefault;
  666.  
  667.     if (yychk[yyn=yyact[yyn]]==yychar) {
  668.         /* valid shift */
  669.         yychar = -1;
  670. #ifdef UNION
  671.         yyunion(&yyval, &yylval);
  672. #else
  673.         yyval = yylval;
  674. #endif
  675.         yystate = yyn;
  676.         if (yyerrflag>0)
  677.             --yyerrflag;
  678.         goto yystack;
  679.  
  680.     }
  681.  
  682. yydefault:
  683.  
  684.     /* default state action */
  685.  
  686.     if ((yyn=yydef[yystate])== -2) {
  687.         if (yychar<0)
  688.             if ((yychar=yylex())<0)
  689.                 yychar = 0;
  690.         /* look through exception table */
  691.  
  692.         for (yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2)
  693.             ; /* VOID */
  694.  
  695.         for (yyxi+=2; *yyxi >= 0; yyxi+=2) {
  696.             if (*yyxi==yychar)
  697.                 break;
  698.         }
  699.         if ((yyn=yyxi[1])<0)
  700.             return(0);   /* accept */
  701.     }
  702.  
  703.     if (yyn==0) {
  704.         /* error */
  705.         /* error ... attempt to resume parsing */
  706.  
  707.         switch (yyerrflag) {
  708.             case 0: /* brand new error */
  709.                     yyerror( "syntax error" );
  710.  
  711. yyerrlab:           ++yynerrs;
  712.  
  713.             case 1:
  714.             case 2: /* incompletely recovered error ... try again */
  715.  
  716.                     yyerrflag = 3;
  717.  
  718.                     /* find a state where "error" is a legal shift action */
  719.  
  720.                     while (yyps>=yys) {
  721.                         yyn = yypact[*yyps] + YYERRCODE;
  722.                         if (yyn>=0 && yyn<YYLAST
  723.                                    && yychk[yyact[yyn]]==YYERRCODE) {
  724.                             yystate = yyact[yyn];
  725.                             /* simulate a shift of "error" */
  726.                             goto yystack;
  727.                         }
  728.                         yyn = yypact[*yyps];
  729.  
  730.                         /* the current yyps has no shift on "error",
  731.                            pop stack */
  732.  
  733. #ifdef YYDEBUG
  734.                         if (yydebug)
  735.                             printf("error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1]);
  736. #endif
  737.  
  738.                         --yyps;
  739.                         --yypv;
  740.                     }
  741.  
  742.                     /* there is no state on the stack with an error shift
  743.                        ... abort */
  744.  
  745. yyabort:            return(1);
  746.  
  747.  
  748.             case 3: /* no shift yet; clobber input char */
  749. #ifdef YYDEBUG
  750.                     if (yydebug)
  751.                         printf("error recovery discards char %d\n", yychar);
  752. #endif
  753.  
  754.                     if (yychar==0)
  755.                         goto yyabort; /* don't discard EOF, quit */
  756.                     yychar = -1;
  757.                     goto yynewstate;   /* try again in the same state */
  758.         }
  759.     }
  760.  
  761.     /* reduction by production yyn */
  762.  
  763. #ifdef YYDEBUG
  764.     if (yydebug)
  765.         printf("reduce %d\n",yyn);
  766. #endif
  767.     yyps -= yyr2[yyn];
  768.     yypvt = yypv;
  769.     yypv -= yyr2[yyn];
  770. #ifdef UNION
  771.     yyunion(&yyval, &yypv[1]);
  772. #else
  773.     yyval = yypv[1];
  774. #endif
  775.     yym=yyn;
  776.     /* consult goto table to find next state */
  777.     yyn = yyr1[yyn];
  778.     yyj = yypgo[yyn] + *yyps + 1;
  779.     if (yyj>=YYLAST || yychk[yystate=yyact[yyj]]!= -yyn)
  780.         yystate = yyact[yypgo[yyn]];
  781.     switch(yym) {
  782.         
  783. case 1:
  784. # line 72
  785. {inputExpr = yypvt[-0];        sp-=1;} break;
  786. case 2:
  787. # line 73
  788. {inputExpr = letrec(yypvt[-0],yypvt[-1]); sp-=2;} break;
  789. case 3:
  790. # line 74
  791. {valDefns  = yypvt[-1];        sp-=3;} break;
  792. case 4:
  793. # line 75
  794. {syntaxError("input");} break;
  795. case 5:
  796. # line 77
  797. {yyval = gc2(yypvt[-2]);} break;
  798. case 6:
  799. # line 78
  800. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  801. case 7:
  802. # line 79
  803. {yyval = gc0(NIL);} break;
  804. case 8:
  805. # line 80
  806. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  807. case 9:
  808. # line 81
  809. {syntaxError("definition");} break;
  810. case 10:
  811. # line 86
  812. {typeDefn(yypvt[-1],yypvt[-2],yypvt[-0]);      sp-=4;} break;
  813. case 11:
  814. # line 87
  815. {dataDefn(yypvt[-1],yypvt[-2],rev(yypvt[-0])); sp-=4;} break;
  816. case 12:
  817. # line 89
  818. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  819. case 13:
  820. # line 90
  821. {yyval = yypvt[-0];} break;
  822. case 14:
  823. # line 91
  824. {syntaxError("type defn lhs");} break;
  825. case 15:
  826. # line 93
  827. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  828. case 16:
  829. # line 94
  830. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  831. case 17:
  832. # line 96
  833. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  834. case 18:
  835. # line 97
  836. {yyval = yypvt[-0];} break;
  837. case 19:
  838. # line 98
  839. {yyval = yypvt[-0];} break;
  840. case 20:
  841. # line 109
  842. {yyval = gc3(ap(QUAL,pair(yypvt[-2],yypvt[-0])));} break;
  843. case 21:
  844. # line 110
  845. {yyval = yypvt[-0];} break;
  846. case 22:
  847. # line 112
  848. {yyval = gc1(checkContext(yypvt[-0]));} break;
  849. case 23:
  850. # line 114
  851. {yyval = yypvt[-0];} break;
  852. case 24:
  853. # line 115
  854. {yyval = gc3(ap(ap(ARROW,yypvt[-2]),yypvt[-0]));} break;
  855. case 25:
  856. # line 116
  857. {syntaxError("type expression");} break;
  858. case 26:
  859. # line 118
  860. {yyval = yypvt[-0];} break;
  861. case 27:
  862. # line 119
  863. {yyval = yypvt[-0];} break;
  864. case 28:
  865. # line 121
  866. {yyval = yypvt[-0];} break;
  867. case 29:
  868. # line 122
  869. {yyval = yypvt[-0];} break;
  870. case 30:
  871. # line 123
  872. {yyval = gc2(UNIT);} break;
  873. case 31:
  874. # line 124
  875. {yyval = gc3(yypvt[-1]);} break;
  876. case 32:
  877. # line 125
  878. {yyval = gc3(buildTuple(yypvt[-1]));} break;
  879. case 33:
  880. # line 126
  881. {yyval = gc3(ap(LIST,yypvt[-1]));} break;
  882. case 34:
  883. # line 128
  884. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  885. case 35:
  886. # line 129
  887. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  888. case 36:
  889. # line 131
  890. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  891. case 37:
  892. # line 132
  893. {yyval = gc3(cons(yypvt[-0],cons(yypvt[-2],NIL)));} break;
  894. case 38:
  895. # line 137
  896. {fixDefn(LEFT_ASS,yypvt[-2],yypvt[-1],yypvt[-0]); sp-=3;} break;
  897. case 39:
  898. # line 138
  899. {fixDefn(RIGHT_ASS,yypvt[-2],yypvt[-1],yypvt[-0]);sp-=3;} break;
  900. case 40:
  901. # line 139
  902. {fixDefn(NON_ASS,yypvt[-2],yypvt[-1],yypvt[-0]);  sp-=3;} break;
  903. case 41:
  904. # line 141
  905. {yyval = gc1(checkPrec(yypvt[-0]));} break;
  906. case 42:
  907. # line 142
  908. {yyval = gc0(mkInt(DEF_PREC));} break;
  909. case 43:
  910. # line 144
  911. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  912. case 44:
  913. # line 145
  914. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  915. case 45:
  916. # line 147
  917. {yyval = yypvt[-0];} break;
  918. case 46:
  919. # line 148
  920. {yyval = yypvt[-0];} break;
  921. case 47:
  922. # line 149
  923. {yyval = gc1(varMinus);} break;
  924. case 48:
  925. # line 151
  926. {yyval = yypvt[-0];} break;
  927. case 49:
  928. # line 152
  929. {yyval = gc3(yypvt[-1]);} break;
  930. case 50:
  931. # line 154
  932. {yyval = yypvt[-0];} break;
  933. case 51:
  934. # line 155
  935. {yyval = gc3(yypvt[-1]);} break;
  936. case 52:
  937. # line 160
  938. {primDefn(intOf(yypvt[-3]),yypvt[-2],yypvt[-0]); sp-=4;} break;
  939. case 53:
  940. # line 162
  941. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  942. case 54:
  943. # line 163
  944. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  945. case 55:
  946. # line 164
  947. {syntaxError("primitive defn");} break;
  948. case 56:
  949. # line 166
  950. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  951. case 57:
  952. # line 171
  953. {classDefn(intOf(yypvt[-2]),yypvt[-1],yypvt[-0]); sp-=3;} break;
  954. case 58:
  955. # line 172
  956. {instDefn(intOf(yypvt[-2]),yypvt[-1],yypvt[-0]);  sp-=3;} break;
  957. case 59:
  958. # line 174
  959. {yyval = gc3(pair(yypvt[-2],yypvt[-0]));} break;
  960. case 60:
  961. # line 175
  962. {yyval = gc1(pair(NIL,yypvt[-0]));} break;
  963. case 61:
  964. # line 177
  965. {yyval = gc4(yypvt[-1]);} break;
  966. case 62:
  967. # line 178
  968. {yyval = gc0(NIL);} break;
  969. case 63:
  970. # line 180
  971. {yyval = gc4(yypvt[-1]);} break;
  972. case 64:
  973. # line 181
  974. {yyval = gc0(NIL);} break;
  975. case 65:
  976. # line 183
  977. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  978. case 66:
  979. # line 184
  980. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  981. case 67:
  982. # line 186
  983. {yyval = gc3(sigdecl(yypvt[-1],yypvt[-2],yypvt[-0]));} break;
  984. case 68:
  985. # line 187
  986. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  987. case 69:
  988. # line 192
  989. {yyval = gc3(sigdecl(yypvt[-1],yypvt[-2],yypvt[-0]));} break;
  990. case 70:
  991. # line 193
  992. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  993. case 71:
  994. # line 195
  995. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  996. case 72:
  997. # line 196
  998. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  999. case 73:
  1000. # line 198
  1001. {yyval = gc2(letrec(yypvt[-0],yypvt[-1]));} break;
  1002. case 74:
  1003. # line 199
  1004. {yyval = yypvt[-0];} break;
  1005. case 75:
  1006. # line 201
  1007. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1008. case 76:
  1009. # line 202
  1010. {yyval = gc1(grded(rev(yypvt[-0])));} break;
  1011. case 77:
  1012. # line 204
  1013. {yyval = gc4(yypvt[-1]);} break;
  1014. case 78:
  1015. # line 206
  1016. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1017. case 79:
  1018. # line 207
  1019. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1020. case 80:
  1021. # line 209
  1022. {yyval = gc4(pair(yypvt[-1],pair(yypvt[-2],yypvt[-0])));} break;
  1023. case 81:
  1024. # line 216
  1025. {yyval = gc5(pair(yypvt[-4],pair(yypvt[-0],yypvt[-3])));} break;
  1026. case 82:
  1027. # line 217
  1028. {yyval = gc4(pair(yypvt[-3],pair(yypvt[-0],yypvt[-2])));} break;
  1029. case 83:
  1030. # line 219
  1031. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1032. case 84:
  1033. # line 220
  1034. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1035. case 85:
  1036. # line 222
  1037. {yyval = yypvt[-0];} break;
  1038. case 86:
  1039. # line 223
  1040. {yyval = gc3(varMinus);} break;
  1041. case 87:
  1042. # line 225
  1043. {yyval = yypvt[-0];} break;
  1044. case 88:
  1045. # line 226
  1046. {yyval = gc3(yypvt[-1]);} break;
  1047. case 89:
  1048. # line 228
  1049. {yyval = yypvt[-0];} break;
  1050. case 90:
  1051. # line 229
  1052. {yyval = gc3(yypvt[-1]);} break;
  1053. case 91:
  1054. # line 234
  1055. {yyval = gc4(ap(LAMBDA,
  1056.                              pair(rev(yypvt[-2]),
  1057.                                   pair(yypvt[-1],yypvt[-0]))));} break;
  1058. case 92:
  1059. # line 237
  1060. {yyval = gc6(letrec(yypvt[-3],yypvt[-0]));} break;
  1061. case 93:
  1062. # line 238
  1063. {yyval = gc6(ap(COND,triple(yypvt[-4],yypvt[-2],yypvt[-0])));} break;
  1064. case 94:
  1065. # line 239
  1066. {yyval = gc6(ap(CASE,pair(yypvt[-4],rev(yypvt[-1]))));} break;
  1067. case 95:
  1068. # line 240
  1069. {yyval = gc3(ap(ESIGN,pair(yypvt[-2],yypvt[-0])));} break;
  1070. case 96:
  1071. # line 241
  1072. {yyval = yypvt[-0];} break;
  1073. case 97:
  1074. # line 242
  1075. {syntaxError("expression");} break;
  1076. case 98:
  1077. # line 244
  1078. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1079. case 99:
  1080. # line 245
  1081. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1082. case 100:
  1083. # line 247
  1084. {yyval = yypvt[-0];} break;
  1085. case 101:
  1086. # line 248
  1087. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  1088. case 102:
  1089. # line 249
  1090. {yyval = gc1(tidyInfix(yypvt[-0]));} break;
  1091. case 103:
  1092. # line 251
  1093. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  1094. case 104:
  1095. # line 252
  1096. {yyval = gc5(ap(ap(yypvt[-1],
  1097.                             ap(ap(yypvt[-3],singleton(yypvt[-4])),
  1098.                                                            yypvt[-2])),yypvt[-0]));} break;
  1099. case 105:
  1100. # line 256
  1101. {if (isInt(yypvt[-0]))
  1102.                          yyval = gc2(mkInt(-intOf(yypvt[-0])));
  1103.                      else
  1104.                          yyval = gc2(ap(varNegate,yypvt[-0]));
  1105.                     } break;
  1106. case 106:
  1107. # line 261
  1108. {yyval = yypvt[-0];} break;
  1109. case 107:
  1110. # line 263
  1111. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  1112. case 108:
  1113. # line 264
  1114. {yyval = yypvt[-0];} break;
  1115. case 109:
  1116. # line 266
  1117. {yyval = yypvt[-0];} break;
  1118. case 110:
  1119. # line 267
  1120. {yyval = gc3(ap(ASPAT,pair(yypvt[-2],yypvt[-0])));} break;
  1121. case 111:
  1122. # line 268
  1123. {yyval = gc2(ap(LAZYPAT,yypvt[-0]));} break;
  1124. case 112:
  1125. # line 269
  1126. {yyval = gc1(WILDCARD);} break;
  1127. case 113:
  1128. # line 270
  1129. {yyval = yypvt[-0];} break;
  1130. case 114:
  1131. # line 271
  1132. {yyval = gc2(UNIT);} break;
  1133. case 115:
  1134. # line 272
  1135. {yyval = yypvt[-0];} break;
  1136. case 116:
  1137. # line 273
  1138. {yyval = yypvt[-0];} break;
  1139. case 117:
  1140. # line 274
  1141. {yyval = yypvt[-0];} break;
  1142. case 118:
  1143. # line 275
  1144. {yyval = yypvt[-0];} break;
  1145. case 119:
  1146. # line 276
  1147. {yyval = gc3(yypvt[-1]);} break;
  1148. case 120:
  1149. # line 277
  1150. {yyval = gc3(buildTuple(yypvt[-1]));} break;
  1151. case 121:
  1152. # line 278
  1153. {yyval = gc3(yypvt[-1]);} break;
  1154. case 122:
  1155. # line 279
  1156. {yyval = gc4(ap(yypvt[-1],yypvt[-2]));} break;
  1157. case 123:
  1158. # line 280
  1159. {yyval = gc4(ap(ap(varFlip,yypvt[-2]),yypvt[-1]));} break;
  1160. case 124:
  1161. # line 281
  1162. {yyval = gc4(ap(ap(varFlip,yypvt[-2]),yypvt[-1]));} break;
  1163. case 125:
  1164. # line 283
  1165. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1166. case 126:
  1167. # line 284
  1168. {yyval = gc3(cons(yypvt[-0],cons(yypvt[-2],NIL)));} break;
  1169. case 127:
  1170. # line 286
  1171. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1172. case 128:
  1173. # line 287
  1174. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1175. case 129:
  1176. # line 289
  1177. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1178. case 130:
  1179. # line 291
  1180. {yyval = gc2(letrec(yypvt[-0],yypvt[-1]));} break;
  1181. case 131:
  1182. # line 292
  1183. {yyval = yypvt[-0];} break;
  1184. case 132:
  1185. # line 294
  1186. {yyval = gc1(grded(rev(yypvt[-0])));} break;
  1187. case 133:
  1188. # line 295
  1189. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1190. case 134:
  1191. # line 297
  1192. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1193. case 135:
  1194. # line 298
  1195. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1196. case 136:
  1197. # line 300
  1198. {yyval = gc4(pair(yypvt[-1],pair(yypvt[-2],yypvt[-0])));} break;
  1199. case 137:
  1200. # line 305
  1201. {yyval = gc0(nameNil);} break;
  1202. case 138:
  1203. # line 306
  1204. {yyval = gc1(ap(FINLIST,cons(yypvt[-0],NIL)));} break;
  1205. case 139:
  1206. # line 307
  1207. {yyval = gc1(ap(FINLIST,rev(yypvt[-0])));} break;
  1208. case 140:
  1209. # line 308
  1210. {yyval = gc3(ap(LISTCOMP,
  1211.                             pair(yypvt[-2],rev(yypvt[-0]))));} break;
  1212. case 141:
  1213. # line 310
  1214. {yyval = gc3(ap(ap(varFromTo,yypvt[-2]),yypvt[-0]));} break;
  1215. case 142:
  1216. # line 311
  1217. {yyval = gc4(ap(ap(varFromThen,yypvt[-3]),yypvt[-1]));} break;
  1218. case 143:
  1219. # line 312
  1220. {yyval = gc2(ap(varFrom,yypvt[-1]));} break;
  1221. case 144:
  1222. # line 313
  1223. {yyval = gc5(ap(ap(ap(varFromThenTo,
  1224.                                                                yypvt[-4]),yypvt[-2]),yypvt[-0]));} break;
  1225. case 145:
  1226. # line 316
  1227. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1228. case 146:
  1229. # line 317
  1230. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1231. case 147:
  1232. # line 319
  1233. {yyval = gc3(ap(FROMQUAL,pair(yypvt[-2],yypvt[-0])));} break;
  1234. case 148:
  1235. # line 320
  1236. {yyval = gc3(ap(QWHERE,pair(yypvt[-2],yypvt[-0])));} break;
  1237. case 149:
  1238. # line 321
  1239. {yyval = gc1(ap(BOOLQUAL,yypvt[-0]));} break;
  1240. case 150:
  1241. # line 327
  1242. {yyval = gc2(yypvt[-0]);} break;
  1243. case 151:
  1244. # line 328
  1245. {yyval = yypvt[-0];} break;
  1246. case 152:
  1247. # line 330
  1248. {yyval = yypvt[-0];} break;
  1249. case 153:
  1250. # line 331
  1251. {yyerrok;
  1252.                                          if (canUnOffside()) {
  1253.                                              unOffside();
  1254.                          /* insert extra token on stack*/
  1255.                          push(NIL);
  1256.                          pushed(0) = pushed(1);
  1257.                          pushed(1) = mkInt(row);
  1258.                      }
  1259.                                          else
  1260.                                              syntaxError("definition");
  1261.                                         } break;/* End of actions */
  1262.     }
  1263.     goto yystack;  /* stack new state and value */
  1264.  
  1265. }
  1266.